﻿using System;
using UniRx;
using UniRx.Triggers;
using UnityEngine;
using UnityEngine.UI;

namespace Studio
{
	// Token: 0x0200054A RID: 1354
	public class ChangeFocus : MonoBehaviour
	{
		// Token: 0x17000438 RID: 1080
		// (get) Token: 0x06002299 RID: 8857 RVA: 0x000D0554 File Offset: 0x000CE754
		// (set) Token: 0x0600229A RID: 8858 RVA: 0x000D055C File Offset: 0x000CE75C
		public int select
		{
			get
			{
				return this.m_Select;
			}
			set
			{
				this.m_Select = value;
				base.enabled = (this.m_Select != -1);
			}
		}

		// Token: 0x0600229B RID: 8859 RVA: 0x000D0578 File Offset: 0x000CE778
		private void ChangeTarget()
		{
			if (Input.GetKey(KeyCode.LeftShift) | Input.GetKey(KeyCode.RightShift))
			{
				this.m_Select--;
				if (this.m_Select < 0)
				{
					this.m_Select = this.selectable.Length - 1;
				}
			}
			else
			{
				this.m_Select = (this.m_Select + 1) % this.selectable.Length;
			}
			if (this.selectable[this.m_Select])
			{
				this.selectable[this.m_Select].Select();
			}
		}

		// Token: 0x0600229C RID: 8860 RVA: 0x000D0610 File Offset: 0x000CE810
		private void Start()
		{
			this.select = -1;
			(from _ in this.UpdateAsObservable()
			where base.enabled
			where this.@select != -1
			where Input.GetKeyDown(KeyCode.Tab)
			select _).Subscribe(delegate(Unit _)
			{
				this.ChangeTarget();
			});
		}

		// Token: 0x040023B1 RID: 9137
		[SerializeField]
		private Selectable[] selectable;

		// Token: 0x040023B2 RID: 9138
		private int m_Select = -1;
	}
}
